package com.rd.sys.service.analysis.result;

import java.util.List;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.rd.sys.dto.client.analysis.SchemeResultData;
import com.rd.sys.dto.client.store.Data;
import com.rd.sys.dto.client.store.Result;

public interface ResultService {
    /**
     * 查询某个素材的原始数据
     * 
     * @param userCode
     * @param projectCode
     * @param schemeCode
     * @param materialCode
     * @return
     */
    public List<SchemeResultData> queryResultRawDataByMaterial(String userCode, String projectCode, String schemeCode,
            String materialCode) throws Exception;;

    /**
     * 查询某个素材的注视点数据
     * 
     * @param userCode
     * @param projectCode
     * @param schemeCode
     * @param materialCode
     * @return
     */
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public List<SchemeResultData> queryResultFixationDataByMaterial(String userCode, String projectCode,
            String schemeCode, String materialCode) throws Exception;;

    /**
     * 查询某个素材的数据(注视点数据和原始数据)
     * 
     * @param userCode
     * @param projectCode
     * @param schemeCode
     * @param materialCode
     * @return
     */
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public List<SchemeResultData> queryResultDataByMaterial(String userCode, String projectCode, String schemeCode,
            String materialCode) throws Exception;;

    /**
     * 查询方案中的所有被试信息
     * 
     * @param userCode
     * @param projectCode
     * @return
     */
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public List<Result> queryResultList(String userCode, String projectCode, String schemeCode) throws Exception;;

    /**
     * 查询某个方案中指定的被试信息
     * 
     * @param userCode
     * @param projectCode
     * @param schemeCode
     * @param resultCode
     * @return
     * @throws Exception
     */
    public Result queryResult(String userCode, String projectCode, String schemeCode, String resultCode)
            throws Exception;

    /**
     * 查询某个方案中指定的被试信息顺序索引
     * 
     * @param userCode
     * @param projectCode
     * @param schemeCode
     * @param resultCode
     * @return (从0开始,未查到返回null)
     * @throws Exception
     */
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public Integer queryResultIndex(String userCode, String projectCode, String schemeCode, String resultCode)
            throws Exception;

    /**
     * 从被试描述文件中读取被试信息
     * 
     * @param userCode
     * @return
     * @throws Exception
     */
    public List<Result> readResultList(String key) throws Exception;

    /**
     * 读取每个被试数据
     * 
     * @param userCode
     * @return
     * @throws Exception
     */
    public List<Data> readDataList(String key) throws Exception;

    /**
     * 修改方案中的所有被试信息（问卷信息）
     * 
     * @param userno
     * @param userCode
     * @param projectCode
     * @param schemeCode
     * @param resultList
     *            新的被试信息
     * @return
     */
    public void modifyResultList(String userCode, String projectCode, String schemeCode, List<Result> resultList)
            throws Exception;

    /**
     * 同步结果信息
     * 
     * @param userno
     * @param userCode
     * @param projectCode
     * @param schemeCode
     * @param result
     *            待新增的结果
     * @param addFlag
     *            是否新增标志
     * @throws Exception
     */
    public void syncResult(Integer userno, String userCode, String projectCode, String schemeCode, Result result,
            boolean addFlag) throws Exception;

    /**
     * 对同步的结果原始文件做处理. 生成: (1) 各类图形分析数据; (2) 注视点统计数据; (3)扫视点统计数据
     * 
     * @param userno
     * @param userCode
     * @param projectCode
     * @param schemeCode
     * @param resultCode
     * @throws Exception
     */
    public void syncResultData(Integer userno, String userCode, String projectCode, String schemeCode, String resultCode)
            throws Exception;

    /**
     * 计算所有结果的属性详情描述
     * 
     * @param userCode
     * @param projectCode
     * @param schemeCode
     * @param resultList
     * @throws Exception
     */
    public void calcResultAttribute(String userCode, String projectCode, String schemeCode, List<Result> resultList)
            throws Exception;

    /**
     * 计算某个结果的属性详情描述
     * 
     * @param userCode
     * @param projectCode
     * @param schemeCode
     * @param result
     * @throws Exception
     */
    public void calcResultAttribute(String userCode, String projectCode, String schemeCode, Result result)
            throws Exception;
}
